package com.wqr.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wqr.dao.ChannelDao;
import com.wqr.dao.StoreDao;
import com.wqr.pojo.Channel;
import com.wqr.pojo.ChannelExample;

@Service
public class ChannelServiceImp implements ChannelService{
	@Autowired
	public ChannelDao channelDao;
	
	public List<Channel> list() throws Exception {
		//ChannelExample example = new ChannelExample();
		Channel channel = new Channel();
		//List<Channel> list = channelDao.selectByExample(example);
		List<Channel> list = channelDao.selectByDIY(channel);
		return list;
	}
	public List<Channel> listAll() throws Exception {
		ChannelExample example = new ChannelExample();
		List<Channel> list = channelDao.selectByExample(example);
		return list;
	}
	public int delectChannel(Integer channelId) throws Exception {
		int a = channelDao.deleteByPrimaryKey(channelId);
		if(a > 0) {
			return 1;
		}else {
			return 0;
		}
	}
	public int insertChannel(Channel channel) throws Exception {
		int a = channelDao.insertSelective(channel);
		if(a > 0) {
			return 1;
		}else {
			return 0;
		}
	}
	public int updateChannel(Channel channel) throws Exception {
		int a = channelDao.updateByPrimaryKeySelective(channel);
		if(a > 0) {
			return 1;
		}else {
			return 0;
		}
	}

	public List<Channel> selectChannel(Channel channel) throws Exception {
		List<Channel> list = channelDao.selectByWhere(channel);
		return list;
	}

	public Channel selectByPrimaryKey(Integer channelId) throws Exception {
		Channel list = channelDao.selectByPrimaryKey(channelId);
		return list;
	}


}
